IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'ChapterGet')
	BEGIN
		DROP  Procedure  ChapterGet
	END

GO

CREATE Procedure ChapterGet
@ChapterID Int, 
@CreatorID Int = Null
AS
If(@CreatorID Is Null )
Begin
	Select 
	 ChapterID,
	SagaID,
	Title,
	Header,
	Footer,
	StartMonth,
	StartYear,
	EndMonth,
	EndYear,
	ViewOrder,
	CreatorID,
    AccessType,
	IsPrivate,
	LastUpdated,
	CreatedDate
	From Chapter
	Where ChapterID = @ChapterID
END
Else
Begin
	Select 
	 ChapterID,
	SagaID,
	Title,
	Header,
	Footer,
	StartMonth,
	StartYear,
	EndMonth,
	EndYear,
	ViewOrder,
	CreatorID,
    AccessType,
	IsPrivate,
	LastUpdated,
	CreatedDate
	From Chapter
	Where ChapterID = @ChapterID And IsPrivate= 0 Or CreatorID = @CreatorID 
END

GO




